package com.kfm.jdbc.day04;

import java.io.InputStream;

public class Demo04 {

    public static void main(String[] args) throws Exception{
//        File file = new File("db.properties");
//
//        System.out.println(file.exists());
//        System.out.println(file.getAbsolutePath());

        // 通过类加载器获取类路径资源文件的输入流
        InputStream resourceAsStream = Demo04.class.getResourceAsStream("db.properties");
        System.out.println(new String(resourceAsStream.readAllBytes()));

//        URL resource = Demo04.class.getResource("db.properties");
//        System.out.println(resource.getPath());

//        String name = "db.properties";
//        // classLoader 类加载器，用于将类加载到内存中
//        URL resource = Demo04.class.getClassLoader().getResource(name);
//        System.out.println(resource.getPath());
//        InputStream resourceAsStream = Demo04.class.getClassLoader().getResourceAsStream(name);
//        System.out.println(new String(resourceAsStream.readAllBytes()));
    }
}
